<template>
  <div class="seller" ref="seller">
    <div class="seller-content">
      <div class="overview">
        <div class="title">{{seller.name}}</div>
        <div class="desc border-1px">
          <star :size="36" :score="seller.score"></star>
          <span class="text">({{seller.ratingCount}})</span>
          <span class="text sell-count">月售{{seller.sellCount}}单</span>
        </div>
        <ul class="remark">
          <li class="block">
            <h2>起送价</h2>
            <div class="text">
              <span class="stress">{{seller.minPrice}}</span>元
            </div>
          </li>
          <li class="block">
            <h2>商家配送</h2>
            <div class="text">
              <span class="stress">{{seller.deliveryPrice}}</span>元
            </div>
          </li>
          <li class="block">
            <h2>平均配送时间</h2>
            <div class="text">
              <span class="stress">{{seller.deliveryTime}}</span>分钟
            </div>
          </li>
        </ul>
      </div>
      <split></split>
      <div class="bulletin">
        <div class="title">公告与活动</div>
        <div class="text border-1px">{{seller.bulletin}}</div>
      </div>
      <ul class="supports" v-if="seller.supports">
        <li v-for="(item,index) in seller.supports" class="support-item">
          <span class="icon" :class="classMap[index]"></span>
          <span class="text">{{item.description}}</span>
        </li>
      </ul>
      <split></split>
      <div class="pics">
        <div class="title">商家实景</div>
        <div class="pics-wrapper" v-if="seller.pics && seller.pics.length">
          <ul class="pics-list">
            <li class="pic-item" v-for="pic in seller.pics">
              <img :src="pic" width="120" height="90">
            </li>
          </ul>
        </div>
      </div>
      <split></split>
      <div class="infos">
        <div class="title border-1px">商家信息</div>
        <ul class="infos-list border-1px">
          <li class="info-item" v-for="info in seller.infos">
            <p>{{info}}</p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import BScroll from 'better-scroll'
  import Vue from 'vue'
  import star from '../../components/star/star.vue'
  import split from '../../components/split/split.vue'
  import supports from '../../components/supports/supports.vue'
  export default {
    props: {
      seller: {
        type: Object
      }
    },
    created(){
      this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']

    },
    watch: {
      seller(){
        this._initScroll()
      }
    },
    mounted(){
//        console.log(this.seller)
      this._initScroll()

    },
    components: {
      star,
      split
    },
    methods: {
      _initScroll(){
        this.$nextTick(() => {
          if (!this.scroll) {
            this.scroll = new BScroll(this.$refs.seller, {
              click: true
            })
          } else {
            this.scroll.refresh()
          }
        })
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "../../common/stylus/mixin.styl"
  .seller
    position: absolute
    top: 174px
    bottom: 0
    width: 100%
    overflow: hidden
    background: #fff
    .overview
      padding: 0 18px
      .title
        margin-top: 18px
        color: rgb(7, 17, 27)
        line-height: 14px
        font-size: 14px
      .desc
        padding: 8px 0 18px
        border-1px(rgba(7, 17, 27, 0.1))
        font-size: 0
        .star
          display: inline-block
          vertical-align: top
          margin: 0 8px 0 0
        .text
          color: rgb(77, 85, 93)
          line-height: 18px
          font-size: 10px
          &.sell-count
            margin-left: 12px
      .remark
        display: flex
        padding: 18px 0
        .block
          flex: 1
          border-right: 1px solid rgba(7, 17, 27, 0.1)
          text-align: center
          &:last-child
            border-right: none
          h2
            margin-bottom: 4px
            color: rgb(147, 153, 159)
            line-height: 10px
            font-size: 10px
          .text
            color: rgb(7, 17, 27)
            line-height: 24px
            font-size: 10px
            .stress
              font-size: 24px
    .bulletin
      padding: 0 18px
      .title
        margin-top: 18px
        color: rgb(7, 17, 27)
        line-height: 14px
        font-size: 14px
      .text
        padding: 8px 12px 16px
        border-1px(rgba(7, 17, 27, 0.1))
        color: rgb(240, 20, 20)
        line-height: 24px
        font-size: 12px
    .supports
      padding: 0 18px
      .support-item
        padding: 16px 12px
        border-1px(rgba(7, 17, 27, 0.1))
        font-size: 0
        &:last-child
          border-none()
        .icon
          display: inline-block
          margin-right: 6px
          width: 16px
          height: 16px
          vertical-align: top
          background-size: 100%
          &.decrease
            bg-image("decrease_4")
          &.discount
            bg-image("discount_4")
          &.guarantee
            bg-image("guarantee_4")
          &.invoice
            bg-image("invoice_4")
          &.special
            bg-image("special_4")
        .text
          font-size: 12px
          line-height: 16px
    .pics
      padding: 0 18px
      .title
        margin-top: 18px
        color: rgb(7, 17, 27)
        line-height: 14px
        font-size: 14px
      .pics-wrapper
        margin-top: 12px
        width: 100%
        overflow: hidden
        .pics-list
          white-space: nowrap
          font-size: 0
          .pic-item
            display: inline-block
            margin-right: 6px

    .infos
      padding: 0 18px
      .title
        padding-top: 18px
        padding-bottom: 12px
        border-1px(rgba(7, 17, 27, 0.1))
        color: rgb(7, 17, 27)
        line-height: 14px
        font-size: 14px
      .infos-list
        .info-item
          padding: 16px 12px
          border-1px(rgba(7, 17, 27, 0.1))
          color: rgb(7, 17, 27)
          line-height: 16px
          font-size: 12px
          &:last-child
            border-none()
</style>
